/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modele;

import java.util.GregorianCalendar;

/**
 *
 * @author Alex
 */
public class Insurance {
    protected Integer idInsurance;
    protected String carRegistration;
    protected GregorianCalendar subscription;
    protected GregorianCalendar endOfValidity;
    protected Type type;

    public Insurance(String carRegistration, Type type) {
        this.carRegistration = carRegistration;
        this.type = type;
        this.subscription = new GregorianCalendar();
        this.endOfValidity = (GregorianCalendar) this.subscription.clone();
        /* The default validity is 1 year */
        this.endOfValidity.add(GregorianCalendar.YEAR, 1);
    }

    public String getCarRegistration() {
        return carRegistration;
    }

    public void setCarRegistration(String carRegistration) {
        this.carRegistration = carRegistration;
    }

    public GregorianCalendar getEndOfValidity() {
        return endOfValidity;
    }

    public void setEndOfValidity(GregorianCalendar endOfValidity) {
        this.endOfValidity = endOfValidity;
    }

    public Integer getId() {
        return idInsurance;
    }

    public void setId(Integer id) {
        this.idInsurance = id;
    }

    public GregorianCalendar getSubscription() {
        return subscription;
    }

    public void setSubscription(GregorianCalendar subscription) {
        this.subscription = subscription;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }
    
    public enum Type {
        ALLRISK, THIRDPARTY;
    }

    @Override
    public boolean equals(Object obj) {
        return this.carRegistration.equalsIgnoreCase
                ( ( (Insurance) obj ).getCarRegistration() ) ? true : false;
    }
    
    
}
